/**
 * 
 */
package com.speaktoitcookbook.dao.proxy;

import java.sql.Connection;
import java.util.List;

import com.speaktoitcookbook.bean.ThirdAccount;
import com.speaktoitcookbook.bean.UserInfo;
import com.speaktoitcookbook.dao.IThirdAccountDao;
import com.speaktoitcookbook.dao.impl.ThirdAccountDaoImpl;
import com.speaktoitcookbook.db.Database;

/**
 * @author 赛艳志
 * 
 */
public class ThirdAccountDaoProxy implements IThirdAccountDao {
    private Connection conn;
    private IThirdAccountDao dao;

    public ThirdAccountDaoProxy() {
        this.conn = Database.getInstance().getConnection();
        this.dao = new ThirdAccountDaoImpl(conn);
    }

    @Override
    public boolean doCreate(ThirdAccount thirdAccount) {
        boolean result = false;
        if (null != thirdAccount) {
            result = dao.doCreate(thirdAccount);
        }
        Database.close(conn);
        return result;
    }

    @Override
    public boolean doDelete(ThirdAccount thirdAccount) {
        boolean result = false;
        if (null != thirdAccount) {
            result = dao.doDelete(thirdAccount);
        }
        Database.close(conn);
        return result;
    }

    @Override
    public boolean doUpdate(ThirdAccount thirdAccount) {
        boolean result = false;
        if (null != thirdAccount) {
            result = dao.doUpdate(thirdAccount);
        }
        Database.close(conn);
        return result;
    }

    @Override
    public List<ThirdAccount> getThirdAccount(String userID) {
        List<ThirdAccount> result = null;
        if ((null != userID) && (!userID.isEmpty())) {
            result = dao.getThirdAccount(userID);
        }
        Database.close(conn);
        return result;
    }

    @Override
    public List<UserInfo> getThirdAccount(Object... params) {
        List<UserInfo> result = null;
        if (null != params) {
            result = dao.getThirdAccount(params);
        }
        Database.close(conn);
        return result;
    }
}
